package com.calm.cdemo.myview;

import android.content.Intent;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.TextView;

import com.calm.cdemo.R;
import com.calm.cdemo.anim.CircleMenu;
import com.calm.cdemo.anim.FrameAnim;
import com.calm.cdemo.anim.ObjectAnim;
import com.calm.cdemo.anim.TweenAnim;
import com.calm.cdemo.anim.ValueAnim;
import com.calm.cdemo.base.BaseActivity;
import com.calm.cdemo.bean.MenuBean;
import com.calm.clibrary.rvadapter.CommRvAdapter;
import com.calm.clibrary.rvadapter.CommRvHolder;

import java.util.ArrayList;
import java.util.List;

/**
 * Create by Calm
 * 2020/4/30 16:27
 */
public class MyViewMenu extends BaseActivity {
    @Override
    protected void init() {
        setTitle("自定义View系列");
        RecyclerView rvList = findViewById(R.id.myviewmenu_rv_list);
        rvList.setLayoutManager(new LinearLayoutManager(mActivity));
        rvList.addItemDecoration(new DividerItemDecoration(mActivity, LinearLayoutManager.VERTICAL));
        CommRvAdapter<MenuBean> adapter = new CommRvAdapter<MenuBean>(mActivity,getMenus(),R.layout.main_item) {
            @Override
            public void bindData(CommRvHolder holder, final MenuBean data, int position) {
                TextView tvText = holder.getViw(R.id.main_item_tv_name);
                tvText.setText(data.name);
                holder.setCommRvOnItemClickListener(new CommRvHolder.CommRvOnItemClickListener() {
                    @Override
                    public void onItemClickListener(int position) {
                        startActivity(new Intent(mActivity,data.toClass));
                    }
                });
            }
        };
        rvList.setAdapter(adapter);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.myviewmenu;
    }
    private List<MenuBean> getMenus(){
        List<MenuBean> menus = new ArrayList<>();
        MenuBean b0 = new MenuBean();
        b0.name = "绘制基础";
        b0.toClass = DrawBase.class;
        b0.description = "";
        menus.add(b0);
        return menus;
    }
}
